package com.iweb.handler;

import com.iweb.exception.AccountException;
import com.iweb.exception.PassWordException;
import com.iweb.resp.R;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@CrossOrigin
@RestControllerAdvice
public class BaseHandler {


    @ExceptionHandler(value = {AccountException.class, PassWordException.class})
    public R<?> handlerLogin(RuntimeException e) {
        return R.fail(e.getLocalizedMessage());
    }

    @ExceptionHandler(value = RuntimeException.class)
    public R<?> handler(RuntimeException e) {
        return R.fail(e.getLocalizedMessage());
    }


}
